<div class="container">
	<div class="bg-putih">
		<div class="jdl-page row">
			<div class="col-xs-8">
				<?php echo isset($judul)?$judul:'<font color="#ccc">Judul Belum Diberikan</font>'; ?>
			</div>			
		</div>
		<div class="clearfix"></div>
		<?php
      $KdKelompok = $this->session->userdata('kelompok');
      $KdObat     = $this->session->userdata('obat');
      $id_petugas = $this->session->userdata('petugas');
    ?>
		<?php echo display_flash(); ?>
		<div class="row">
      <div class="col-md-2">
        <div class="btn-group btn-group-sm" role="group">
          <a href="<?php echo site_url('statistik_pembelian/excel') ?>" class="btn btn-warning"><i class="fa fa-file-excel-o"></i> Unduh Excel</a>
        </div>
      </div>
      <div class="col-xs-10" style="float:right">
        <div class="input-group-3">
          <?php echo form_open('statistik_pembelian/cari'); ?>
          <button id="btn-search" type="submit" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-search"></span></button>
          <select id="selector" class="form-control input-sm" name="obat" style="width:20%">
            <option value=""> - - Pilih Obat - - </option>     
            <?php
              foreach ($obat as $value) {
                if($value['KdObat'] == $KdObat){
                  $s = "selected";
                }else{
                  $s = "";
                }
                echo "<option value='".$value['KdObat']."' $s>".$value['NmObat']."</option>";
              }
            ?>         
          </select>   
          <span id="frm-input">
            <select name="kelompok" class="form-control input-sm" id="form-no-radius" style="width:19%">  
              <option value=""> - - Pilih Kelompok - - </option>  
              <?php
                foreach ($kelompok as $value) {
                  if($value['KdKelompok'] == $KdKelompok){
                    $s = "selected";
                  }else{
                    $s = "";
                  }
                  echo "<option value='".$value['KdKelompok']."' $s>".$value['NmKelompok']."</option>";
                }
              ?>
            </select>
            <select name="petugas" class="form-control input-sm form-no-radius" style="width:19%">
              <option value=""> - - Pilih Petugas - - </option>
              <?php
                foreach ($petugas as $value) {
                  if($value['id'] == $id_petugas){
                    $s = "selected";
                  }else{
                    $s = "";
                  }
                  echo "<option value='".$value['id']."' $s>".$value['nickname']."</option>";
                }
              ?>  
            </select>
            <input id="after" type="text" name="tgl_akhir" class="form-control input-sm" placeholder="Tanggal Akhir" style="width:19%" value="<?php echo $this->session->userdata('tgl_akhir') ?>"/>
            <input id="before" type="text" name="tgl_awal" class="form-control input-sm" placeholder="Tanggal Awal" style="width:19%" value="<?php echo $this->session->userdata('tgl_awal') ?>"/>
          </span>
          <?php echo form_close(); ?> 
        </div>
      </div>
    </div>
				<table class="table table-striped table-hover margintop20">
					<tr>
						<th width="5%">No</th>
						<th width="15%">Kode Obat</th>
						<th>Nama Obat</th>
						<th width="20%">Item</th>
						<th width="20%">Transaksi</th>
					</tr>
					<?php
						if(count($results) > 0){
							foreach ($results as $value) {
								?>
									<tr>
										<td align="center"><?php echo $ordinal_num++ ?></td>
										<td align="center"><?php echo $value['KdObat']; ?></td>
										<td><?php echo $value['NmObat']; ?></td>
										<td align="center"><?php echo formatAngka($value['item']); ?></td>
										<td align="right"><?php echo formatAngka($value['transaksi']); ?></td>
									</tr>
								<?php
							}
						}else{
							?>
								<tr>
									<td colspan="5" align="center">Tidak Ada Data</td>
								</tr>
							<?php	
						}
					?>
				</table>
				<center style="margin-top:-30px;">
          <ul class="pagination">
            <?php echo $pagination; ?>
          </ul>
        </center>
		</div>
	</div>
</div>

<script type="text/javascript">
  $(document).ready(function(){
    $('#after, #before').datepicker({
      dateFormat: "dd/mm/yy",
      changeMonth: true,
      changeYear: true
    });
  });
</script>